#ifndef __AUTH_H__
#define __AUTH_H__

#include "../utils/vec.h"
#include "../utils/uthash.h"
#include "../utils/meven.h"

typedef struct {
    int id;
    char username[64];
    char password[64];
} user_info;

typedef struct {
    user_info *user;
    struct list_head list;
} user_node_t;

typedef struct {
    char* username;
    user_node_t *node;
    UT_hash_handle hh;
} user_map;

typedef struct {
    int user_count;
    user_node_t user_list;
    user_map* map;
}user_db;

extern user_db *users;

// 初始化用户数据库
void load_user_db();

// 添加用户
int add_user(const char* username, const char* password);

// 验证用户
user_info* verify_user(const char* username, const char* password);

// 获取用户信息
user_info* get_user(const char* username);


//注册账号
void auth_register(even_detail *event, http_request_t *request);

//登录账号
void auth_login(even_detail *event, http_request_t *request);

#endif